// 用户相关接口
import request from '@/utils/request'

/**
 * 账号密码登录
 * @param account
 * @param password
 * @returns {*|AxiosPromise}
 */
export const userAccountLogin = ({
  account,
  password
}) => {
  return request('/login', 'post', {
    account,
    password
  })
}

/**
 * 获取登录验证码
 * @param params
 * @returns {*|AxiosPromise}
 */
export const userMobileLoginMsg = (params) => {
  return request('/login/code', 'get', params)
}

/**
 * 手机、验证码登录
 * @param data
 * @returns {*|AxiosPromise}
 */
export const userMobileLogin = (data) => {
  return request('/login/code', 'post', data)
}

/**
 * QQ登录
 * @param unionId
 * @param source
 * @returns {*|AxiosPromise}
 */
export const userQQLogin = (unionId, source = 1) => {
  return request('/login/social', 'post', {
    unionId,
    source
  })
}

/**
 * 获取qq绑定的时候短息验证码
 * @param mobile
 */
export const userQQBindCode = (params) => {
  return request('/login/social/code', 'get', params)
}

/**
 * qq绑定后登录
 * @param params
 * @returns {*|AxiosPromise}
 */
export const userQQBindLogin = (data) => {
  return request('/login/social/bind', 'post', data)
}

/**
 * 校验用户是否唯一
 * @param account
 * @returns {*|AxiosPromise}
 */
export const userAccountCheck = (account) => {
  return request('/register/check', 'get', { account })
}

/**
 * 注册时获取短信验证码
 * @param data
 * @returns {*|AxiosPromise}
 */
export const userQQPatchCode = (mobile) => {
  return request(' /register/code', 'get', { mobile })
}

/**
 * 注册
 * @param data
 * @returns {*|AxiosPromise}
 */
export const userQQPatchLogin = ({
  unionId,
  mobile,
  code,
  account,
  password
}) => {
  return request(`/login/social/${unionId}/complement`, 'post', {
    unionId,
    mobile,
    code,
    account,
    password
  })
}
